<template>
  <a-modal :visible="show" width="90vw" title="引用申请记录" :maskClosable="false" :key="show" @cancel="show = false">
    <QuoteListView ref="QuoteListView" />
    <template slot="footer">
      <a-button @click="show = false">取消</a-button>
    </template>
  </a-modal>
</template>
<script>
import { TableMixin } from '@/mixins/TableMixin'
import { CodesMixin } from '@/mixins/CodesMixin'
export default {
  name: 'QuoteListModal',
  mixins: [TableMixin, CodesMixin],
  components: {
    QuoteListView: () => import('@/views/tech/enginee/quote/QuoteListView'),
  },
  data() {
    return {
      show: false,
      tech: {},
      columns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: '45px',
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '状态',
          align: 'center',
          width: '100px',
          dataIndex: 'quoteStatus',
          customCell: () => {
            return this.customCellRender(100)
          },
          customRender: (text, record) => {
            return this.tooltipRender(this.getCodeNames(text, '技术库-引用申请状态'), record)
          },
        },
        {
          title: '申请单号',
          align: 'center',
          width: '150px',
          dataIndex: 'approvalNo',
          customCell: () => {
            return this.customCellRender(150)
          },
          customRender: (text, record) => {
            return this.tooltipActiveRender(text, record, 'doDetail')
          },
        },
        {
          title: '申请理由',
          align: 'center',
          width: '250px',
          dataIndex: 'approvalReason',
          customCell: () => {
            return this.customCellRender(120)
          },
          customRender: (text, record) => {
            return this.tooltipRender(text, record)
          },
        },
        {
          title: '申请人',
          align: 'center',
          width: '100px',
          dataIndex: 'quoteUserName',
          customCell: () => {
            return this.customCellRender(100)
          },
          customRender: (text, record) => {
            return this.tooltipRender(text, record)
          },
        },
        {
          title: '申请人',
          align: 'center',
          width: '100px',
          dataIndex: 'quoteCreateTime',
          customCell: () => {
            return this.customCellRender(100)
          },
          customRender: (text, record) => {
            return this.tooltipRender(text, record)
          },
        },
      ],
    }
  },
  mounted() {
    this.fetchCodes([
      '工程技术库状态',
      '工程技术库-技术类型',
      '技术库-技术类别（专业）',
      '技术库-文件形式',
      '技术库-引用申请状态',
    ])
  },
  methods: {
    open(tech) {
      this.show = true
      this.tech = tech
      this.$nextTick(() => {
        this.$refs.QuoteListView.setColumns(this.columns)
        this.$refs.QuoteListView.setTechId(this.tech.id)
      })
    },
    doDetail(record) {
      let urlJump = this.$router.resolve({ path: `/engineeTech/quote?id=` + record.quoteId })
      window.open(urlJump.href, '_blank')
    },
  },
}
</script>
